Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/watrli_rpl_udp: initial commit [DO NOT MERGE, just 4 testing] #5

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

BytesGalore
Copy link

This is a small example initializing RPL on a node and starting an UDP server.
After 30sec a message is sent to the DODAG root (DAG-ID)

@BytesGalore BytesGalore force-pushed the watrli_rpl_udp_example branch 3 times, most recently from 311a71e to 12fc236 Compare February 27, 2015 09:01
int sock;
sockaddr6_t sa;
int bytes_sent;
sock = socket_base_socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, this creates a new socket every time is is used to send a packet... Is this intentional? If so, why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup every-time a new socket.
There's no real reason for that. My initial intention was to use this function only once for testing purposes.
So the function prototype could be changed to e.g.
static void watr_li_udp_send(int sock, char* payload, size_t payload_size)
and the socket_base_close(sock); at the end of this function should be removed then.
The socket then can be created for instance here and provided as parameter here (with the new prototype).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main has changed a bit in the plant_node master anyway.. ;) I'd create the socket in watr_li_setup_node() and close it at the end of my new main. Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants